package com.mapull.jvm;

import org.apache.commons.lang3.ThreadUtils;

import java.util.Collection;
import java.util.Set;

/**
 * @author mapull
 */
public class FindThreads {

    public static void main(String[] args) {
        getThreads();
    }

    private static void  getThread(){
        Set<Thread> threads = Thread.getAllStackTraces().keySet();
        for(Thread td : threads){
            System.out.printf("线程 %-20s  状态 %-20s  优先级  %d \n", td.getName(), td.getState().name(), td.getPriority());
        }
    }

    private static void  getThreads(){
        Collection<Thread> threads = ThreadUtils.getAllThreads();
        for(Thread td : threads){
            System.out.printf("线程 %-20s  状态 %-20s  优先级  %d \n", td.getName(), td.getState().name(), td.getPriority());
        }
    }
}
